/**
 * 新增-报修记录js
 */

$(function () {
    //时间选择器
    laydate.render({
        elem: '#repairTimeId',
        type: 'datetime'
    });
});

var vm = new Vue({
    el: '#dpLTE',
    data: {
        projectRepairRecord: {
            id: 0,
            reporter: {},
            reporterId: {},
            repairTime: formatDate(new Date(), 'yyyy-MM-dd hh:mm:ss'),
            hospitalId: '0',
            faultClassificationId: '0',
            repairStatusId: '0',
            resolvingStatusId: '0',
        },
        optionsHospital: [],
        optionsFaultClassification: [],
        optionsRepairStatus: [],
        optionsResolvingStatus: [],
    },
    methods: {
        acceptClick: function () {
            if (!$('#form').Validform()) {
                return false;
            }
            $.SaveForm({
                url: '../../project/repair/save?_' + $.now(),
                param: vm.projectRepairRecord,
                success: function (data) {
                    $.currentIframe().vm.load();
                }
            });
        },
        getUser: function () {
            $.getJSON("/sys/user/info?_" + $.now(), function (r) {
                vm.projectRepairRecord.reporter = r.user.realName;
                vm.projectRepairRecord.reporterId = r.user.userId;
            });
        },
        getHospitals: function () {
            $.getJSON("/sys/macro/value?_" + $.now() + "&value=客户", function (r) {
                vm.optionsHospital = r;
            });
        },
        getFaultClassifications: function () {
            $.getJSON("/sys/macro/value?_" + $.now() + "&value=故障分类", function (r) {
                vm.optionsFaultClassification = r;
            });
        },
        getRepairStatus: function () {
            $.getJSON("/sys/macro/value?_" + $.now() + "&value=报修状态", function (r) {
                vm.optionsRepairStatus = r;
            });
        },
        getResolvingStatus: function () {
            $.getJSON("/sys/macro/value?_" + $.now() + "&value=解决状态", function (r) {
                vm.optionsResolvingStatus = r;
            });
        },
    }
});
vm.getUser();
vm.getHospitals();
vm.getFaultClassifications();
vm.getRepairStatus();
vm.getResolvingStatus();
